home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / miscuni.com / PRNUTIL.DOC < prev    next >
Encoding:
Text File  |  1989-05-25  |  6.8 KB  |  221 lines

  1. PrnUtil
  2. -------
  3.  
  4. PrnUtil contains routines to handle printer output while checking
  5. for printer errors as well as user input.  PrnUtil keeps track of
  6. line and page numbers making report pagination as easy as
  7. possible. It includes routines for redirecting output to disk
  8. files as well as redirecting to a network printer (Novell,
  9. requires Turbo Power's B-Tree Filer - NetWare unit).  It also
  10. includes routines for printing formatted heading and footing
  11. lines.  This unit requires Turbo Professional 5.0 for compilation
  12. as well as the Messages and IOError units which I have written.
  13. If Network printing is desired, requires B-Tree Filer's NetWare
  14. unit and DataEntry, a small field entry unit which was written
  15. for small field entry tasks before TPEntry was released and
  16. modified to work with version 5.0 of the Turbo Power routines.
  17.  
  18.  
  19.  
  20.  
  21. Constants
  22.  
  23.   MaxLineLength = 132
  24.  
  25. This is the maximum length for strings passed to PrnUtil's print
  26. routines.
  27.  
  28.   PrnDatePic : DateString = 'mm/dd/yy'
  29.   PrnTimePic : DateString = 'hh:mm te'
  30.  
  31. These set the way the time and date will appear in printed
  32. strings formatted using the PercentExpand function.
  33.  
  34. Types
  35.  
  36.   PageLine = String[MaxLineLength]
  37.  
  38. This defines the base string type passed to all print routines.
  39.  
  40.   JustType = (Left, Right, middle);
  41.  
  42. Describes how strings can be justified by the PrintJust
  43. procedure.
  44.  
  45. Variables
  46.  
  47.   PrnPort : byte
  48.  
  49. This is the printer port that PrnUtil will use when sending
  50. output to the printer, 0 for LPT1, 1 for LPT2, etc.  Defaults to
  51. 0.
  52.  
  53.   PrnCanceled : boolean
  54.  
  55. This will be true if a print job has been cancelled by a user by
  56. pressing ESC at a printer error message or by pausing the
  57. printing and pressing ESC.  While PrnCanceled is true, all print
  58. commands are ignored.
  59.  
  60.   PrnStatus : byte
  61.  
  62. PrnStatus will always contain the status of the printer after the
  63. last print operation.  PrnStatus is a bit mapped byte with the
  64. following information:
  65.  
  66.   7   6   5   4   3   2   1   0
  67.   │   │   │   │   │           │
  68.   │   │   │   │   │           └── Printer time out
  69.   │   │   │   │   └────────────── Printer I/O error
  70.   │   │   │   └────────────────── Printer online
  71.   │   │   └────────────────────── Printer out of paper
  72.   │   └────────────────────────── Printer Acknowledge
  73.   └────────────────────────────── Printer not busy
  74.  
  75.  
  76.  
  77.   PrintToFile : boolean
  78.  
  79. If set to True, all printer output will be routed to the file
  80. PrnFile which must be opened by the calling program using
  81. OpenPrnFile which sets this to true if successful.
  82.  
  83.   PrnIOResult : word
  84.  
  85. The saved value of IOResult if a file I/O error occurs when
  86. printing to a disk file.
  87.  
  88.   PrnFile : Text
  89.  
  90. File to print to if PrnToFile is true.  This file must be opened
  91. by the calling program using OpenPrnFile.
  92.  
  93.   CurrLine : byte
  94.   CurrPage : word
  95.  
  96. The current line and page numbers being printed.  These should
  97. not be altered by the calling program in most circumstances, they
  98. are exported mostly for inspection by the calling program for
  99. pagination.
  100.  
  101.   PageLength,
  102.   PageWidth : byte
  103.  
  104. The current number of lines per page and number of columns per
  105. page.  Defaults to 66 lines, 80 columns.
  106.  
  107.   FootingLine : byte
  108.  
  109. This is the line number where the footing will be placed by the
  110. NewPage procedure.
  111.  
  112.   PrnInFileName : String[64]
  113.  
  114. This is the string that will print for the %F in strings passed
  115. to the PercentExpand function.
  116.  
  117.   PrnErrorAttr : byte
  118.  
  119. This is the attribute of the pop up windows describing printer
  120. errors or print job status.
  121.  
  122.   NetOK : boolean
  123.  
  124. If network printing is enabled (compiled with the NetPrint
  125. directive defined).  This will be true if the network drivers are
  126. installed and the user is logged in.
  127.  
  128.   Capturing : boolean
  129.  
  130. If network printing is enabled, this will be true if output is
  131. being captured to a network printer.
  132.  
  133. Procedures and Functions
  134.  
  135.   procedure Print(St : PageLine)
  136.  
  137. Prints St to the current printer or file, does not advance to the
  138. next line.  Checks printer status before printing and displays
  139. error message in pop up window promptine user to correct problem
  140. or press ESC.  If a key has been pressed, will prompt user to
  141. press another key to continue or press ESC to cancel printing.
  142.  
  143.   procedure PrintLn(St : PageLine)
  144.  
  145. Prints St to the current printer of file, advancing to the next
  146. line when done.  See Print procedure for more.
  147.  
  148.   function PercentExpand( S: String ): String
  149.  
  150. Formats a string containing embedded commands. The commands
  151. should be preceeded by a percent (%) sign and will be interpreted
  152. and/or replaced as follows:
  153.  
  154.         %F - Replace with PrnInfileName which must be initialized by
  155.              the calling program.
  156.         %# - Replace with current page number.
  157.         %T - Replace with system time (formatted by PrnTimePic).
  158.         %D - Replace with system date (Formatted by PrnDatePic).
  159.         %< - Left justify entire line.
  160.         %> - Right justify entire line (dependent on PageWidth).
  161.         %[ - Alternate Left justify Even/Odd pages
  162.         %] - Alternate Right justify Even/Odd pages
  163.  
  164.   procedure PrintJust(Line : PageLine;Just:Justtype)
  165.  
  166. Prints a line justified in the manner specified by the Just
  167. parameter.  Uses PrintLn to do the printing.
  168.  
  169.   procedure PrnSkiplines(Num : Integer)
  170.  
  171. Skips the specified number of lines.
  172.  
  173.   procedure NewPage(Footer : PageLine)
  174.  
  175. Advances to the top of the next page.  Prints PercentExpand(
  176. Footer ) on line specified by FootingLine if it advances past
  177. that line.
  178.  
  179.  procedure PrnReset
  180.  
  181. Resets the line and page counting variables to 1.
  182.  
  183.   procedure InitPrinter
  184.  
  185. Initializes the printer port specified by PrnPort.
  186.  
  187.   function OpenPrnFile(FName: String): boolean
  188.  
  189. Assigns and opens PrnFile for output and sets the variable
  190. PrintToFile to true if file is opened successfully.  Notifies
  191. user in pop up window of I/O errors. If OpenPrnFile fails, the
  192. variable PrnCanceled is set to True.
  193.  
  194.   function ClosePrnFile(Fname: String): boolean
  195.  
  196. Closes the PrnFile if it has been opened previously.  Notifies
  197. users of any errors closing the file and prompts for retry or
  198. ESC to cancel.  If ClosePrnFile fails (user pressed ESC to
  199. cancel), PrnCancelled is set to True.  This routine will reset
  200. the variable PrnToFile to false in all cases.  FName is used in
  201. reporting the error to the user.
  202.  
  203.  
  204.  
  205. The following routines are exported only if the program is
  206. compiled with the NetPrint directive defined.
  207.  
  208.   function SetCapture( On : boolean ): boolean
  209.  
  210. Starts or stops network print capturing.  Returns true if
  211. successful.
  212.  
  213.   procedure SetPringOptions
  214.  
  215. Allows user to select whether to print to network and to select a
  216. network printer number.  If network printing is selected, it
  217. calls SetCapture.  If user presses ESC while answering questions,
  218. PrnCanceled will be set to True on exit.
  219.  
  220.  
  221.